
namespace gen {

	template <class FunctorT>
	template <typename ContextT>
	class if_expr2<FunctorT>::if_expr2_initializator 
	{
	private:
		ContextT m_context;
		FunctorT m_expr;
		
	public:
		if_expr2_initializator(FunctorT const& expr, ContextT const& c)
		: m_expr(expr), m_context(c)
		{}

		template <class IteratorT>
		bool operator()(IteratorT const& i)
		{
			m_context.current(i);
			return m_expr(m_context);
		}
	};

	template <class FunctorT>
	template <typename ContextT>
	domain<typename ContextT::iterator_t>
	if_expr2<FunctorT>::evaluate(ContextT const& c) const
	{
		typedef typename ContextT::iterator_t iterator_t;
		typedef if_expr2_initializator<ContextT> initializator_t;
		initializator_t init(m_expr, c);
		domain<iterator_t> result(c.domain().first(), c.domain().last(), init);
		return result;
	}

	template <class T>
	inline if_expr2<T>
	if2_g(const T & f)
    {
        return if_expr2<T>(f);
    }

}
